/**
 * @class 本星系群对象实体
 * @author DuskyHuang 圣子
 * @description 本星系群是被银河系更上一级的范围系统，主要包含银河系在内的三个次级星系群和一堆离散星系。
*/

import { _decorator, instantiate } from 'cc';
import { core } from 'cfw';
import { LAYER_MAIN_3D, LOCAL_TO_SOLAR, M31_TO_SOLAR, Res } from 'const';
import { createNodeAt, setParticles } from 'helpers';
import { Task, TaskNames } from 'notifications';
import { CosmicScope } from './cosmic-scope';
const { ccclass } = _decorator;

@ccclass('cocosmos.LocalGroupGalaxy')
export class LocalGroupGalaxy extends CosmicScope {

    protected _substructure_key: substructures = 'subgroups';
    protected _attenuation: attenuation = [5.4, 6.3, 7.5, 7.8];

    protected createSubParticles(): void {
        this._subparts = createNodeAt("Perversive Companions", LAYER_MAIN_3D, this.node);
        const CompanionsGPU = core.res.getPrefab(COMPANIONS_GPU);
        [MilkyCompanions, M31Companions, PerversiveCompanions].forEach(args =>
            setParticles(instantiate(CompanionsGPU), args, this._subparts));
    }

    protected approachScope1stTime(): void {
        // GPU Particle Texture Seems Not Support Dynamic Loading
        // core.notify(Task.Load.DYNAMIC_TEX, TaskNames.TEX_CMP_GALAXIES);
    }
}

const { Prefabs: { COMPANIONS_GPU } } = Res;

const MilkyCompanions: IParticleLike = {
    num: 700,
    sizes: [0.006, 0.012],
    radius: 0.8,
    thickness: 0.7,
    random: 0.2,
};

const M31Companions: IParticleLike = {
    num: 700,
    sizes: [0.012, 0.024],
    position: M31_TO_SOLAR,
    radius: 1.5,
    thickness: 0.7,
    random: 0.3,
};

const PerversiveCompanions: IParticleLike = {
    num: 3600,
    sizes: [0.036, 0.06],
    radius: 7,
    position: LOCAL_TO_SOLAR,
    thickness: 0.5,
    random: 0.6,
};